<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import financialReportexcel from '@/api/financial/financialReportexcel'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()


const numberOperation = (newValue, id, numberName) => {
  financialReportexcel.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  financialReportexcel.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'flyos_financial_reportexcel',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: financialReportexcel.getList,
  recycleApi: financialReportexcel.getRecycleList,
  add: {
    show: true,
    api: financialReportexcel.save,
    auth: ['financial:reportexcel:save']
  },
  edit: {
    show: true,
    api: financialReportexcel.update,
    auth: ['financial:reportexcel:update']
  },
  delete: {
    show: true,
    api: financialReportexcel.deletes,
    auth: ['financial:reportexcel:delete'],
    realApi: financialReportexcel.realDeletes,
    realAuth: ['financial:reportexcel:realDeletes']
  },
  recovery: {
    show: true,
    api: financialReportexcel.recoverys,
    auth: ['financial:reportexcel:recovery']
  },
  import: {
    show: true,
    url: 'financial/reportexcel/import',
    templateUrl: 'financial/reportexcel/downloadTemplate',
    auth: ['financial:reportexcel:import']
  },
  export: {
    show: true,
    url: 'financial/reportexcel/export',
    auth: ['financial:reportexcel:export']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入ID"
    }
  },
  {
    title: "提货订单",
    dataIndex: "prediction_order_id",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入提货订单"
    }
  },
  {
    title: "仓储订单",
    dataIndex: "warehouse_order_id",
    formType: "input",
    search: true
  },
  {
    title: "订单类型",
    dataIndex: "order_type",
    formType: "select",
    search: true,
    multiple: false,
    dict: {
      data: [
        {
          label: "提货订单",
          value: "1"
        },
        {
          label: "仓储订单",
          value: "2"
        }
      ],
      translation: true
    }
  },
  {
    title: "类型",
    dataIndex: "price_type",
    formType: "select",
    search: true,
    commonRules: {
      required: true,
      message: "请输入类型"
    },
    multiple: false,
    dict: {
      name: "price_type",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
    }
  },
  {
    title: "装卸费",
    dataIndex: "handling_fee",
    formType: "input"
  },
  {
    title: "出库费",
    dataIndex: "delivery_fee",
    formType: "input"
  },
  {
    title: "专线使用费",
    dataIndex: "special_fee",
    formType: "input"
  },
  {
    title: "配送服务费",
    dataIndex: "distribution_fee",
    formType: "input"
  },
  {
    title: "暂存费",
    dataIndex: "temporary_storage_fee",
    formType: "input"
  },
  {
    title: "仓储费",
    dataIndex: "storage_fee",
    formType: "input"
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "range",
    search: true,
    addDisplay: false,
    editDisplay: false,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "客户姓名",
    dataIndex: "user_id",
    formType: "input",
    search: true
  }
])
</script>
<script> export default { name: 'financial:reportexcel' } </script>